package org.simple.framework.html.parser.reflect;

import java.lang.reflect.Field;

/**
 * 项目名称：simple-framework
 * 类名称：ReflectUtil
 * 类描述：ReflectUtil
 * 创建时间：2018/9/22
 *
 * @author sisyphus   (E-mail:1620657419@qq.com)
 * @version v1.0
 */
public class ReflectUtil {

    public static <T> T getInstance(Class<T> tClass) {
        try {
            return tClass.newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            System.out.println("构造" + tClass + "失败");
            e.printStackTrace();
        }
        return null;
    }

    public static void setFieldValue(Object object, Field field, Object value) {
        field.setAccessible(true);
        try {
            field.set(object, value);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        field.setAccessible(false);
    }

}
